﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetFlow_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetFlow_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetFlow_V2]
    @FlowID int = 0
AS
BEGIN
SET NOCOUNT ON;

IF @FlowID>0
BEGIN
    -- select the information for the specified flow.
    SELECT
            A.Flow_ID,
            A.Flow_Name,
            Build_Date,
            A.Builder,
            A.Remark,
            A.Style_ID,
            B.Style_NAME
        FROM
            dbo.uds_flow a,
            dbo.uds_flow_style b
        WHERE
            a.style_id = b.style_id
            AND a.flow_id = @FlowID         
END
ELSE
BEGIN
    -- select all flows.
    SELECT
            A.Flow_ID,
            A.Flow_Name,
            Build_Date,
            A.Builder,
            A.Remark,
            A.Style_ID,
            B.Style_NAME
        FROM
            dbo.uds_flow a,
            dbo.uds_flow_style b
        WHERE
            a.style_id = b.style_id
END;

END
GO